< previous page page_523 next page >

Page 523
Assert method using the syntax shown in the following code:
Debug.Assert (boolean expression)
When you are testing your application, this statement will cause the application to enter Break mode with the line containing the statement highlighted (that assumes that the expression evaluates to False). The Debug.Assert statement is very similar to setting a Watch expression with the Break When Value Is True option selected, with the exception that it will break when the expression is False.
The other method of the Debug object is also very useful. The Print method is used to print information directly into the Immediate window using the following syntax:
Debug.Print [output list]
By using the Spc and Tab functions, you can even format the information that is printed in the window. The same functionality and syntax for the Basic Print statement is used for the output list of the Debug Print method.
When debugging your application, you can have as much information as you need printed to the Immediate window to help you track down the problem you are trying to fix.
Note
Don't worry about having the Debug methods in your application; when you compile your application, all of the references to the Debug object are ignored by the compiler.

Special Debugging Considerations..
In any Visual Basic application, certain events can pose some unique problems when debugging your application. It is very important that you are aware of these problems so that you can work around them and not have them confuse you. When using the debugging tools, you are also using some very basic features of your computerthe keyboard and the mouse. But, what happens when the routines that you need to test are the mouse event or keyboard routine?
Breaking During a MouseDown Event
If the execution of the application is halted during a MouseDown event, you may release the mouse button or use the mouse to do any number of other tasks. However, when the application continues, it assumes that the mouse button is still pressed down. You will not get a MouseUp event until you click the mouse button down and then release it. The problem with this scenario is if you have a breakpoint in the MouseDown event. When you click the mouse button down in Run mode, you will press the breakpoint in the

 
< previous page page_523 next page >

If you like this book, buy it!